package com.openlogic.flow.domain.dto;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import org.noear.solon.validation.annotation.NotBlank;

import com.openlogic.common.core.web.validate.V_A;

public class StartFlowTaskDto {

	/**
	 * 业务唯一值id
	 */
	@NotBlank(message = "业务ID不能为空", groups = { V_A.class })
	private String businessId;

	/**
	 * 流程定义编码
	 */
	@NotBlank(message = "流程定义编码不能为空", groups = { V_A.class })
	private String flowDefCode;

	/**
	 * 流程变量，前端会提交一个元素{'entity': {业务详情数据对象}}
	 */
	private Map<String, Object> variables;

	public String getBusinessId() {
		return businessId;
	}

	public void setBusinessId(String businessId) {
		this.businessId = businessId;
	}

	public String getFlowDefCode() {
		return flowDefCode;
	}

	public void setFlowDefCode(String flowDefCode) {
		this.flowDefCode = flowDefCode;
	}

	public void setVariables(Map<String, Object> variables) {
		this.variables = variables;
	}

	public Map<String, Object> getVariables() {
		if (variables == null) {
			return new HashMap<>(16);
		}
		variables.entrySet().removeIf(entry -> Objects.isNull(entry.getValue()));
		return variables;
	}
}
